package com.datn.utils;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class MyOverlay extends Overlay{

	
	public GeoPoint startPoint,endPoint;
	
	
    public GeoPoint getStartPoint() {
		return startPoint;
	}

	public void setStartPoint(GeoPoint startPoint) {
		this.startPoint = startPoint;
	}

	public GeoPoint getEndPoint() {
		return endPoint;
	}

	public void setEndPoint(GeoPoint endPoint) {
		this.endPoint = endPoint;
	}

	public MyOverlay(GeoPoint start, GeoPoint end){
    	startPoint=start;
    	endPoint=end;
    }   

    public void draw(Canvas canvas, MapView mapv, boolean shadow){
        super.draw(canvas, mapv, shadow);

        Projection projection=mapv.getProjection();
        
        Paint mPaint = new Paint();
        mPaint.setDither(true);
        mPaint.setColor(Color.parseColor("#88ff0000"));
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setStrokeWidth(3);
        mPaint.setAntiAlias(true);
        mPaint.setAlpha(122);
        
        Point p1 = new Point();
        Point p2 = new Point();
        Path path = new Path();

        projection.toPixels(startPoint, p1);
        projection.toPixels(endPoint, p2);

        
        
        path.moveTo(p2.x, p2.y);
        path.lineTo(p1.x,p1.y);

        canvas.drawPath(path, mPaint);
    }
    
}